package com.jacky.serial;

import org.junit.Test;

import java.io.*;

public class SerialTests {
    @Test
    public void serialTest01() throws IOException, ClassNotFoundException {
        Student student = new Student();
        student.setName("li");
        student.setAge(18);
        student.setPassword("123465");

        File file = new File("E:/1.txt");

        OutputStream out = new FileOutputStream(file);
        ObjectOutputStream oos = new ObjectOutputStream(out);
        oos.writeObject(student);
        oos.close();

        InputStream in = new FileInputStream(file);
        ObjectInputStream ois = new ObjectInputStream(in);
        final Object object = ois.readObject();


        System.out.println(object.getClass());
        System.out.println(student);
        System.out.println(object);
        System.out.println(student == object);
    }
}
